package com.woniuxy.usercoachassemble.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.woniuxy.usercoachassemble.dao.UserinfoMapper;
import com.woniuxy.usercoachassemble.entity.Account;
import com.woniuxy.usercoachassemble.dao.AccountMapper;
import com.woniuxy.usercoachassemble.entity.Userinfo;
import com.woniuxy.usercoachassemble.service.AccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2020-07-10
 */
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> implements AccountService {
    @Autowired
    private  AccountMapper accountMapper;
    @Autowired
    private UserinfoMapper userinfoMapper;

    //查看账户
    @Override
    public  Account selectaccountbyid(int userId){
    //查询账户id
        QueryWrapper<Userinfo> wrapper=new QueryWrapper();
        wrapper.eq("user_id",userId);
        Userinfo userinfo=userinfoMapper.selectOne(wrapper);
        return accountMapper.selectById(userinfo.getAcccountId());

//


    }
    //改变用户状态账户
    @Override
    public void updateaccountbyid(int id){
       Account account=selectaccountbyid(id);
       if (account.getStatus()==0) account.setStatus(1);
       else account.setStatus(0);

       accountMapper.updateById(account);
    }

}
